package com.binvshe.binvshe.organization;

import android.content.Context;
import android.content.Intent;

import com.binvshe.binvshe.common.http.ListDataRequestListener;
import com.binvshe.binvshe.common.http.MyHttpRequest;
import com.binvshe.binvshe.common.http.UrlCenter;
import com.binvshe.binvshe.organization.entity.OpusListEntity;
import com.pachong.android.baseuicomponent.activity.SwipeListActivity;
import com.pachong.android.baseuicomponent.adapter.RecyclerViewBaseAdapter;
import com.pachong.android.framework.httprequest.IHttpRequest;
import com.pachong.android.framework.httprequest.UrlParams;

/**
 * Created by Zoi.
 * E-mail：KyluZoi@gmail.com
 * 2016/9/5
 */
public class OrgCenterActivity extends SwipeListActivity {
    private static final String KEY_CLUB_ID = "CLUB_ID";

//    @InjectExtra(KEY_CLUB_ID)
    int mClubID;
    private int mPage = 0;
    ListDataRequestListener<OpusListEntity> mRequestListener = new ListDataRequestListener(this, OpusListEntity.class);

    public static void start(Context context, int clubID) {
        Intent starter = new Intent(context, OrgCenterActivity.class);
        starter.putExtra(KEY_CLUB_ID, clubID);
        context.startActivity(starter);
    }

    @Override
    public RecyclerViewBaseAdapter createAdapter() {
        return new OpusAdapter(this);
    }

    @Override
    public void onStartLoading() {

    }


    /**
     * 获取列表数据
     */
    public void getOpusList() {
        if (mRequestListener.getResponseDataParser().hasMore()) {
            mPage++;
        }
        IHttpRequest request = new MyHttpRequest(this);
        UrlParams params = new UrlParams();
        params.put("page", mPage + "");
        params.put("size", 6 + "");
        params.put("club_id", mClubID + "");
        request.get(UrlCenter.GET_OPUS, params, mRequestListener);

    }
}
